<?php
	if(isset($_POST['submit'])){
		if(!isset($_POST['allIncludes'])) $_POST['allIncludes'] = 0;
		if($PHPFoxEngine->allIncludes != $_POST['allIncludes']){$PHPFoxEngine->allIncludes = $_POST['allIncludes'];$PHPFoxEngine->saveIniConfig();}
		$PHPFoxEngine->includes = $_POST['includes'];
		echo ($PHPFoxEngine->saveIncludes())? '<div class="success">Sauvegarde effectuée</div>':'<div class="error">Sauvegarde impossible. Veuillez vérifier que le fichier de configuration possède des droits en écriture.</div>';
	}
	$PHPFoxEngine->loadIncludes();
?>
<div id="PHPFoxEngine_classesForm">
    <form action="" method="post">
    	<label>Inclure toutes les classes : <input type="checkbox" name="allIncludes" <?php echo ($PHPFoxEngine->allIncludes)? 'checked="checked"':""; ?>/></label><br/>
        <?php
			if(is_dir('./'.$PHPFoxEngine->classesDir.'/')){
				$directory = opendir('./'.$PHPFoxEngine->classesDir.'/') or die('Erreur');
				while(false !== ($file = readdir($directory))) {
					if($file != '.' && $file != '..' && !is_dir('./'.$PHPFoxEngine->classesDir.'/'.$file)) {
						$checked = (array_search($file,$PHPFoxEngine->includes) === false)? '':'checked';
						echo '<div class="PHPFoxEngine_input"><label><input name="includes[]" value="'.$file.'" type="checkbox" '.$checked.'>'.$file.'</label></div>';
					}
				}
				closedir($directory);
			}		
		?>
        <input type="submit" value="Modifier" name="submit" />
    </form>
</div>